<?php

namespace App\Admin\Extensions;

use Encore\Admin\Form\Field;

class UeEditor extends Field
{
    protected $view = 'admin.ue-editor';

    protected static $css = [

    ];
    public static $isJs=false;
    protected static $js = [
        '/vendor/ueditor-1.4.3.3/ueditor.config.js',
        '/vendor/ueditor-1.4.3.3/_examples/editor_api.js',
        '/vendor/ueditor-1.4.3.3/lang/zh-cn/zh-cn.js',
    ];
    public function render()
    {
        $name = $this->formatName($this->column);
        $this->token = csrf_token();

        $this->script = <<<EOT
        UE.delEditor('{$this->id}');
        var ue = UE.getEditor('{$this->id}');
        $(document).on('pjax:start', function() {
            UE.delEditor('{$this->id}');
            var ue = UE.getEditor('{$this->id}');
        });
EOT;
        return parent::render();
    }

}
